<?php

namespace app\common\model;

use think\Model;

class Login extends Model
{

    //登录校验
    public function login($data){
        $validate = new  \app\common\validate\Login();
        if (!$validate->scene('login')->check($data)){
            return $validate->getError();
        }
        $data['password'] = md5($data['password']);
        $result = $this->where($data)->find();
        if ($result){

//            halt($sessionData);
            session('username',$result['username']);
            session('nickname',$result['nickname']);
            return 1;
        }else{
            return '用户名或者密码错误！';
        }
    }

}
